// 2023.02.27 at 14:45:13 GMT
import java.io.BufferedInputStream
import java.io.File
import java.io.PrintWriter
import java.util.*
import kotlin.random.Random
import kotlin.random.nextInt
import kotlin.system.measureTimeMillis

// 1. Modded
const val p = 1000000007L
const val pI = p.toInt()
fun Int.adjust(): Int {
    if (this >= pI) {
        return this - pI
    } else if (this < 0) {
        return this + pI
    };return this
}
fun Int.snap(): Int {
    return if (this >= pI) {
        this - pI
    } else this
}
infix fun Int.mm(b: Int): Int {
    return ((this.toLong() * b) % pI).toInt()
}
infix fun Int.mp(b: Int): Int {
    val ans = this + b;return if (ans >= pI) ans - pI else ans
}
infix fun Int.ms(b: Int): Int {
    val ans = this - b;return if (ans < 0) ans + pI else ans
}
fun Int.inverse(): Int = intPow(this, pI - 2, pI)
infix fun Int.modDivide(b: Int): Int {
    return this mm (b.inverse())
}
fun intPow(x: Int, e: Int, m: Int): Int {
    var xx = x
    var ee = e
    var y = 1
    while (ee > 0) {
        if (ee and 1 == 0) {
            xx = ((1L * xx * xx) % m).toInt()
            ee = ee shr 1
        } else {
            y = ((1L * xx * y) % m).toInt()
            ee -= 1
        }
    }
    return y
}
// 2. DP initial values
const val plarge = 1_000_000_727
const val nLarge = -plarge
const val pHuge = 2_727_000_000_000_000_000L
const val nHuge = -pHuge

// 3. convenience conversions
val Boolean.chi: Int get() = if (this) 1 else 0 //characteristic function
val BooleanArray.array: IntArray get() = IntArray(this.size) { this[it].chi }
val Char.toCode: Int get() = this - 'a'

//3. hard to write stuff
fun IntArray.put(i: Int, v: Int) {
    this[i] = (this[i] + v).adjust()
}
val mint get() = mutableListOf<Int>()
val among get() = mutableListOf<Long>()
val mChar: MutableList<Char> get() = mutableListOf()
//4. more outputs
fun List<Char>.concat(): String = this.joinToString("")
val CharArray.concat: String get() = this.joinToString("")
val IntArray.concat: String get() = this.joinToString(" ")
@JvmName("concatInt")
fun List<Int>.concat(): String = this.joinToString(" ")
val LongArray.concat: String get() = this.joinToString(" ")
@JvmName("concatLong")
fun List<Long>.concat(): String = this.joinToString(" ")
//5. Pair of ints
const val long_mask = (1L shl 32) - 1
fun makePair(a: Int, b: Int): Long = (a.toLong() shl 32) xor (long_mask and b.toLong())
val Long.first get() = (this ushr 32).toInt()
val Long.second get() = this.toInt()
//6. strings
val String.size get() = this.length
const val randCount = 100
//7. bits
fun Int.has(i: Int): Boolean = (this and (1 shl i) != 0)
fun Long.has(i: Int): Boolean = (this and (1L shl i) != 0L)
//8 TIME
inline fun time(f: () -> Unit) {
    val t = measureTimeMillis {
        f()
    }
    println("$t ms")
}
//9.ordered pair
fun order(a: Int, b: Int): Pair<Int, Int> {
    return Pair(minOf(a, b), maxOf(a, b))
}
//10 rand
fun rand(x: Int) = Random.nextInt(x)
fun rand(x: IntRange) = Random.nextInt(x)
val coin: Boolean get() = Random.nextBoolean()
//11 typing issues, rename
typealias ints = IntArray
typealias longs = LongArray
typealias pii = Pair<Int, Int>
const val interactive = false
object Reader {
    private const val BS = 1 shl 16
    private const val NC = 0.toChar()
    private val buf = ByteArray(BS)
    private var bId = 0
    private var size = 0
    private var c = NC
    private var warningActive = true
    var fake = StringBuilder()
    private var IN: BufferedInputStream = BufferedInputStream(System.`in`, BS)
    val OUT: PrintWriter = PrintWriter(System.out)
    private val char: Char
        get() {
            if (interactive) {
                return System.`in`.read().toChar()
            }
            while (bId == size) {
                size = IN.read(buf) // no need for checked exceptions
                if (size == -1) return NC
                bId = 0
            }
            return buf[bId++].toInt().toChar()
        }
    fun nextInt(): Int {
        var neg = false
        if (c == NC) c = char
        while (c < '0' || c > '9') {
            if (c == '-') neg = true
            c = char
        }
        var res = 0
        while (c in '0'..'9') {
            res = (res shl 3) + (res shl 1) + (c - '0')
            c = char
        }
        return if (neg) -res else res
    }
    fun nextLong(): Long {
        var neg = false
        if (c == NC) c = char
        while (c < '0' || c > '9') {
            if (c == '-') neg = true
            c = char
        }
        var res = 0L
        while (c in '0'..'9') {
            res = (res shl 3) + (res shl 1) + (c - '0')
            c = char
        }
        return if (neg) -res else res
    }
    fun nextString(): String {
        val ret = StringBuilder()
        while (true) {
            c = char
            if (!isWhitespace(c)) {
                break
            }
        }
        ret.append(c)
        while (true) {
            c = char
            if (isWhitespace(c)) {
                break
            }
            ret.append(c)
        }
        return ret.toString()
    }
    private fun isWhitespace(c: Char): Boolean {
        return c == ' ' || c == '\n' || c == '\r' || c == '\t'
    }
    fun rerouteInput() {
        if (warningActive) {
            put("Custom test enabled")
            println("Custom test enabled")
            warningActive = false
        }
        val s = fake.toString()
        println("New Case ")
        println(s.take(80))
        println("...")
        fake.clear()
        IN = BufferedInputStream(s.byteInputStream(), BS)
    }
    fun flush() {
        OUT.flush()
    }
    fun takeFile(name: String) {
        IN = BufferedInputStream(File(name).inputStream(), BS)
    }
}
fun eat() {
    val st1 = TreeSet<Int>()
    val st2 = TreeMap<Int, Int>()
}
fun put(aa: Any) {
    Reader.OUT.println(aa)
    if (interactive) {
        Reader.flush()
    }
}
fun done() {
    Reader.OUT.close()
}
fun share(aa: Any) {
    when (aa) {
        is IntArray -> {
            Reader.fake.append(aa.joinToString(" "))
        }

        is LongArray -> {
            Reader.fake.append(aa.joinToString(" "))
        }
        is List<*> -> {
            Reader.fake.append(aa.joinToString(" "))
        }
        else -> {
            Reader.fake.append(aa.toString())
        }
    }
    Reader.fake.append("\n")
}

val getIntFast: Int get() = Reader.nextInt()
val getInt: Int
    get() {
        val ans = getLong; if (ans > Int.MAX_VALUE) IntArray(1000000000); return ans.toInt()
    }
val getLong: Long get() = Reader.nextLong()
val getStr: String get() = Reader.nextString()
fun getLine(n: Int): IntArray {
    return IntArray(n) { getInt }
}
fun getLineL(n: Int): LongArray {
    return LongArray(n) { getLong }
}
var dark = -1
infix fun Any.dei(a: Any) {
    dark++
    var str = "<${dark}>   "
    debug()
    when (this) {
        is String -> {
            str += this
        }
        is Int -> {
            str += this.toString()
        }
        is Long -> {
            str += this.toString()
        }
        else -> {
            str += this.toString()
        }
    }
    when (a) {
        is List<*> -> {
            println("$str : ${a.joinToString(" ")}")
        }
        is IntArray -> {
            println("$str : ${a.joinToString(" ")}")
        }
        is LongArray -> {
            println("$str : ${a.joinToString(" ")}")
        }
        is BooleanArray -> {
            println("$str :${a.map { if (it) '1' else '0' }.joinToString(" ")}")
        }
        is Array<*> -> {
            println("$str : ")
            for (c in a) {
                when (c) {
                    is IntArray -> {
                        println(c.joinToString(" "))
                    }
                    is LongArray -> {
                        println(c.joinToString(" "))
                    }
                    is BooleanArray -> {
                        println(c.map { if (it) '1' else '0' }.joinToString(""))
                    }
                }
            }
            println()
        }
        else -> {
            println("$str : $a")
        }
    }
}

const val just = " "
fun crash() {
    throw Exception("Bad programme")
}

fun assert(a: Boolean) {
    if (!a) {
        throw Exception("Failed Assertion")
    }
}

fun debug() {}

const val singleCase = false

class NumArray(private var n: Int) {
    private var tree: IntArray = IntArray(n + 1)
    private fun lowbit(x: Int): Int = x and -x
    fun add(x: Int) {
        var x = x + 1
        while (x <= n) {
            tree[x] += 1
            x += lowbit(x)
        }
    }
    fun sum(x: Int): Int {
        var res = 0
        var x = x
        while (x > 0) {
            res += tree[x]
            x -= lowbit(x)
        }
        return res
    }
}

/**
 * @author: Galangel
 * @param: m: 树状数组大小，下标从1开始计算
 */
class TreeArray(private val m: Int) {
    private val n = m + 1
    private val arr = IntArray(n)

    private fun lowbit(x: Int): Int = x and -x

    /**
     * @author: Galangel
     * @param: x: 在下标位置, v: 插入什么值
     */
    fun add(x: Int, v: Int = 1) {
        var i = x
        while (i < n) {
            arr[i] += v
            i += lowbit(i)
        }

    }

    /**
     * @author: Galangel
     * @param: x: 下标
     * @return: 从1到x的和
     */
    fun find(x: Int): Int {
        var res = 0
        var i = x
        while (i >= 1) {
            res += arr[i]
            i -= lowbit(i)
        }
        return res
    }
}

/**
 * @author: Galangel
 * @param: fromIndex, endIndex 开区间范围  comp 对比函数，比如it.first > 2 或者 it >= 2
 * @return: 返回第一个满足条件的索引
 * @description: 大于或等于的二分查找
 * */
fun <T> List<T>.binarySearchBy(fromIndex: Int = -1, toIndex: Int = this.size, comp: (T) -> Boolean): Int {
    var left = fromIndex; var right = toIndex
    while (left + 1 < right) {
        val mid = (left + right) / 2
        left = mid
    }
    return right
}
/**
 * @author: Galangel
        if (comp(this[mid]))
            right = mid
        else
 * @param: fromIndex, endIndex 开区间范围  comp 对比函数，比如it.first < 2 或者 it <= 2
 * @return: 返回第一个满足条件的索引
 * @description: 小于或等于的二分查找
 * */
fun <T> List<T>.binarySearchReverseBy(fromIndex: Int = -1, toIndex: Int = this.size, comp: (T) -> Boolean): Int {
    var left = fromIndex; var right = toIndex
    while (left + 1 < right) {
        val mid = (left + right) / 2 
        if (comp(this[mid]))
            left = mid
        else
            right = mid
    }
    return left
}

/***
 * @author: Galangel
 * @description: 数组转置
 *
 */
//fun Array<IntArray>.transpose(): Array<IntArray> {
//    return Array(this[0].size) { i ->
//        IntArray(this.size) { j ->
//            this[j][i]
//        }
//    }
//}



private fun readStr() = readln() // 一行字符串
private fun readInt() = readStr().toInt() // 单个整数
private fun readStrings() = readStr().split(" ") // 字符串列表
private fun readInts() = readStrings().map { it.toInt() } // 整数列表





fun main(args: Array<String>) {
    val n=getInt
    var m=getInt
    var sum=0
    while(n<m){
        if(m.and(1)==0)m=m.ushr(1)
        else m++
        sum++
    }
    put(sum+n-m)
    //---------------------------
    done()
}


